using MinoChat.Ui.Enums;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace MinoChat.Ui.Controls;

public class IconComboBox : ComboBox
{
    static IconComboBox()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(IconComboBox), new FrameworkPropertyMetadata(typeof(IconComboBox)));
    }
    #region 依赖属性
    // 图标类型枚举
    public static readonly DependencyProperty IconProperty =
        DependencyProperty.Register(
            nameof(Icon),
            typeof(IconType),
            typeof(IconComboBox),
            new PropertyMetadata(IconType.None));
    public IconType Icon
    {
        get => (IconType)GetValue(IconProperty);
        set => SetValue(IconProperty, value);
    }

    // 图标大小，默认18
    public static readonly DependencyProperty IconSizeProperty =
        DependencyProperty.Register(
            nameof(IconSize),
            typeof(double),
            typeof(IconComboBox),
            new PropertyMetadata(22.0));
    public double IconSize
    {
        get => (double)GetValue(IconSizeProperty);
        set => SetValue(IconSizeProperty, value);
    }
    // 图标和文本之间的间距
    public static readonly DependencyProperty SpacingProperty =
        DependencyProperty.Register(
            nameof(Spacing),
            typeof(double),
            typeof(IconComboBox),
            new PropertyMetadata(3.0));
    public double Spacing
    {
        get => (double)GetValue(SpacingProperty);
        set => SetValue(SpacingProperty, value);
    }
    // 背景边框的圆角半径
    public static readonly DependencyProperty CornerRadiusProperty =
        DependencyProperty.Register(
            nameof(CornerRadius),
            typeof(CornerRadius),
            typeof(IconComboBox),
            new PropertyMetadata(new CornerRadius(6)));
    public CornerRadius CornerRadius
    {
        get => (CornerRadius)GetValue(CornerRadiusProperty);
        set => SetValue(CornerRadiusProperty, value);
    }
    // 占位符文本，没有选中任何项时显示的文本
    public static readonly DependencyProperty PlaceholderTextProperty =
        DependencyProperty.Register(
            nameof(PlaceholderText),
            typeof(string),
            typeof(IconComboBox),
            new PropertyMetadata(string.Empty));
    public string PlaceholderText
    {
        get => (string)GetValue(PlaceholderTextProperty);
        set => SetValue(PlaceholderTextProperty, value);
    }
    // 鼠标悬停时的背景色
    public static readonly DependencyProperty HoverBackgroundProperty =
        DependencyProperty.Register(
            nameof(HoverBackground),
            typeof(Brush),
            typeof(IconComboBox),
            new PropertyMetadata(null));
    public Brush HoverBackground
    {
        get => (Brush)GetValue(HoverBackgroundProperty);
        set => SetValue(HoverBackgroundProperty, value);
    }

    // 按下时的背景色
    public static readonly DependencyProperty PressedBackgroundProperty =
        DependencyProperty.Register(
            nameof(PressedBackground),
            typeof(Brush),
            typeof(IconComboBox),
            new PropertyMetadata(null));

    public Brush PressedBackground
    {
        get => (Brush)GetValue(PressedBackgroundProperty);
        set => SetValue(PressedBackgroundProperty, value);
    }

    #endregion
}
